<?php
class IndexAction extends BaseAction{
	
	public function _initialize() {
		parent::_initialize();
	}
	
    public function index(){
   	
        //$pSystemUserGroup = D('SystemUserGroup');    
 		$this->display();
    }

    //菜单
	function menu() {
		$appList = array(
			'initial'=>array('title'=>'首页','url'=>__APP__.'&mod=Index&act=menulist&id=1'),
			'system'=>array('title'=>'系统','url'=>__APP__.'&mod=Index&act=menulist&id=2'),
			'user'=>array('title'=>'用户','url'=>__APP__.'&mod=Index&act=menulist&id=3'),
			'application'=>array('title'=>'应用','url'=>__APP__.'&mod=Index&act=menulist&id=4')
		);
		exit(json_encode($appList));
//        $pNode = D('SystemNode');
//        $list = $pNode->where("pid=0 AND type='admin' AND state=1")->order('ordernum ASC')->findall();
//        foreach ($list as $val){
//        	$name = $val['name'];
//        	$data[$name]['title'] = $val['title'];
//        	$data[$name]['url']   =  __APP__.'/Index/menulist/id/'.$val['id'];
//        }
//		exit(json_encode($data));
	}

	//左侧列表
	function menulist(){
		
		$intId = intval($_GET['id']);
		if($intId=='1'){
			echo '{
			"Home":{"title":"网站概况","node":[
				{"title":"\u9996\u9875","url":"index.php?app=admin&mod=Home&act=index"},
				{"title":"\u52a8\u6001\u7ba1\u7406","url":"index.php?app=admin&mod=Expert&act=feedDel"},
				{"title":"\u66f4\u65b0\u7f13\u5b58","url":"index.php?app=admin&mod=Expert&act=upcache"},
				{"title":"\u5730\u533a\u7ba1\u7406","url":"index.php?app=admin&mod=Expert&act=network"},
				{"title":"\u6570\u636e\u5907\u4efd","url":"index.php?app=admin&mod=Expert&act=backup"}
			]},
			"Info":{"title":"信息发布","node":[
				{"title":"\u6587\u7ae0\u5217\u8868","url":"index.php?app=admin&mod=Cms&act=index"},
				{"title":"\u6dfb\u52a0\u6587\u7ae0\u5206\u7c7b","url":"index.php?app=admin&mod=Cms&act=addCategory"},
				{"title":"\u6dfb\u52a0\u6587\u7ae0","url":"index.php?app=admin&mod=Cms&act=addContent"}
			]}
			}';
		}
		if($intId=='2'){
			echo '{
			"System":{"title":"系统配置","node":[
				{"title":"\u7ad9\u70b9\u8bbe\u7f6e","url":"index.php?app=admin&mod=System&act=index"},
				{"title":"\u9690\u79c1\u8bbe\u7f6e","url":"index.php?app=admin&mod=System&act=privacy"},
				{"title":"\u6ce8\u518c\u914d\u7f6e","url":"index.php?app=admin&mod=System&act=reg"},
				{"title":"\u5e7f\u544a\u7ba1\u7406","url":"index.php?app=admin&mod=System&act=ad_list"},
				{"title":"\u53cb\u60c5\u94fe\u63a5","url":"index.php?app=admin&mod=System&act=links_list"},
				{"title":"\u5ba1\u6838\u8bbe\u7f6e","url":"index.php?app=admin&mod=System&act=auditing"},
				{"title":"\u516c\u544a\u8bbe\u7f6e","url":"index.php?app=admin&mod=System&act=gonggao"},
				{"title":"\u4e3e\u62a5\u7ba1\u7406","url":"index.php?app=admin&mod=System&act=report"},
				{"title":"邮件管理","url":"index.php?app=admin&mod=System&act=email"},
				{"title":"\u9080\u8bf7\u8bbe\u7f6e","url":"index.php?app=admin&mod=System&act=invite"},
				{"title":"\u597d\u53cb\u7ba1\u7406","url":"index.php?app=admin&mod=System&act=friend"},
				{"title":"\u8868\u60c5\u7ba1\u7406","url":"index.php?app=admin&mod=System&act=ico"},
				{"title":"积分规则","url":"index.php?app=admin&mod=System&act=scores"},
				{"title":"附件管理","url":"index.php?app=admin&mod=System&act=attach"},
				{"title":"动态管理","url":"index.php?app=admin&mod=System&act=feed"},
				{"title":"认证设置","url":"index.php?app=admin&mod=System&act=domain"},
				{"title":"计划任务","url":"index.php?app=admin&mod=System&act=schedule"},
				{"title":"用户贡献","url":"index.php?app=admin&mod=Contribute&act=index"},
				{"title":"小工具","url":"index.php?app=portal&mod=data"}
			]},
			"Popedom":{"title":"权限配置","node":[
				{"title":"\u8282\u70b9\u7ba1\u7406","url":"index.php?app=admin&mod=Popedom&act=node"},
				{"title":"\u6743\u9650\u7ba1\u7406","url":"index.php?app=admin&mod=Popedom&act=commision"}
			]},
			"AppManage":{"title":"应用配置","node":[
				{"title":"\u6240\u6709\u7684\u5e94\u7528","url":"index.php?app=admin&mod=AppManage&act=index"},
				{"title":"\u9ed8\u8ba4\u7684\u5e94\u7528","url":"index.php?app=admin&mod=AppManage&act=defapp"},
				{"title":"\u53ef\u9009\u7684\u5e94\u7528","url":"index.php?app=admin&mod=AppManage&act=choice"},
				{"title":"\u5173\u95ed\u7684\u5e94\u7528","url":"index.php?app=admin&mod=AppManage&act=close"},
				{"title":"\u6dfb\u52a0\u5e94\u7528","url":"index.php?app=admin&mod=AppManage&act=add"}
			]},
			"Templet":{"title":"模板管理","node":[
				{"title":"\u901a\u77e5\u6a21\u677f","url":"index.php?app=admin&mod=Templet&act=notify"},
				{"title":"\u52a8\u6001\u6a21\u677f","url":"index.php?app=admin&mod=Templet&act=feed"}
			]}
			}';
		}
		if($intId=='3'){
			echo '{
			"User":{"title":"用户管理","node":[
				{"title":"用户管理","url":"index.php?app=admin&mod=User&act=index"},
				{"title":"用户组管理","url":"index.php?app=admin&mod=Popedom&act=group"},
				{"title":"消息群发","url":"index.php?app=admin&mod=User&act=msg"},
				{"title":"\u6279\u91cf\u7528\u6237\u79ef\u5206","url":"index.php?app=admin&mod=User&act=userscore"}			
			]}
			}';
		}
		if($intId=='4'){
			echo '{
			"Apps":{"title":"应用管理","node":[
				{"title":"问答管理","url":"index.php?app=ask&mod=Admin"},
				{"title":"空间管理","url":"index.php?app=space&mod=Admin"},
				{"title":"博客管理","url":"index.php?app=blog&mod=Admin&act=bloglist"},
				{"title":"团队空间","url":"index.php?app=group&mod=Admin&act=index"},
				{"title":"论坛管理","url":"index.php?app=bbs&mod=Admin&act=index"},
				{"title":"百科管理","url":"index.php?app=wiki&mod=Admin&act=index"},
				{"title":"专题管理","url":"index.php?app=portal&mod=Channel&act=admin"}
			]},
			"AppManage":{"title":"应用配置","node":[
				{"title":"\u6240\u6709\u7684\u5e94\u7528","url":"index.php?app=admin&mod=AppManage&act=index"},
				{"title":"\u9ed8\u8ba4\u7684\u5e94\u7528","url":"index.php?app=admin&mod=AppManage&act=defapp"},
				{"title":"\u53ef\u9009\u7684\u5e94\u7528","url":"index.php?app=admin&mod=AppManage&act=choice"},
				{"title":"\u5173\u95ed\u7684\u5e94\u7528","url":"index.php?app=admin&mod=AppManage&act=close"},
				{"title":"\u6dfb\u52a0\u5e94\u7528","url":"index.php?app=admin&mod=AppManage&act=add"}
			]}
			}';
		}
//        $pNode = D('SystemNode');
//        $list = $pNode->getNodeList($intId);
//    	foreach ($list as $val){
//    		foreach ($val['child'] as $key=>$cval){
//    			$a['title'] = $cval['title'];
//    			$a['url']   = __APP__.'/'.$val['name'].'/'.$cval['name'];
//    			$node[]     = $a;
//    		}
//    		$b['title'] = $val['title'];
//    		$b['node']  = $node;
//    		unset($node);
//    		$name = $val['name'];
//    		$data[$name] = $b;
//    	}
//    	if($intId==4){
//			$apps = D("App")->where("status!=2")->findAll();
//			foreach($apps as $k=>$v){
//				$APP_URL = str_replace('http://{APPS_URL}',SITE_URL.'/apps',$v['url']);
//				$open_apps[$k]["title"] = $v["name"];
//				$open_apps[$k]["url"]   = str_replace('http://{APP_URL}',$APP_URL,$v['url_admin']);
//			}
//			$data['Apps']['node'] = $open_apps;
//    	}
//    	exit(json_encode($data)); 
	}
}
?>